package com.gouaixin.bee.beeframework2.model;

import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.gouaixin.bee.beeframework2.R;
import com.gouaixin.bee.beeframework2.activity.B13_aiBiActivity;
import com.gouaixin.bee.beeframework2.activity.B13_yBiActivity;
import com.gouaixin.bee.beeframework2.activity.B14_vipTequanActivity;
import com.gouaixin.bee.beeframework2.activity.B15_faxinBaoyueActivity;
import com.gouaixin.bee.beeframework2.activity.B16_yuanfenHongniangyueActivity_new;
import com.gouaixin.bee.beeframework2.activity.B23_zhenxinhuaActivity;
import com.gouaixin.bee.beeframework2.activity.E1_GiftShopActivity;
import com.gouaixin.bee.beeframework2.bean.Chongzhi;
import com.gouaixin.bee.beeframework2.tool.mLog;
import com.lidroid.xutils.BitmapUtils;

/**
 * Created by Administrator on 2015/4/17.
 */
//对话框控制器（to表示不可返回，go表示可以返回）
public class DialogModel {

    public static void tiaozhuan(final Context context,final int oldflag,final int newflag){
        switch (newflag){
            case Chongzhi.VIP:
                toVIP(context,"",false);
                break;
            case Chongzhi.Baoyue:
                toBaoyue(context, "");
                break;
            case Chongzhi.Ybi:
                toYbi(context, "");
                break;
            case Chongzhi.Aibi:
                toAibi(context, "");
                break;
            case Chongzhi.Hongliang:
                toHongliang(context, "");
                break;
        }


    }


    public static void toBaoyue(final Context context,String str){
        AlertDialog.Builder builder;
        final AlertDialog alertDialog;

        mLog.e("弹出包月服务对话框");
        View mView = LayoutInflater.from(context).inflate(R.layout.dialog_vipfuwu, null);
//        AbDialogUtil.showDialog(mView);

        builder = new AlertDialog.Builder(context,R.style.my_dialog);
//        builder.setView(mView);
        alertDialog = builder.create();

        alertDialog.setView(mView, 0, 0, 0, 0);
        alertDialog.setCancelable(false);
        alertDialog.show();

        TextView title = (TextView) mView.findViewById(R.id.title);
        TextView content = (TextView) mView.findViewById(R.id.content);
        TextView quxiao = (TextView) mView.findViewById(R.id.quxiao);
        TextView kaitong = (TextView) mView.findViewById(R.id.kaitong);

        title.setText("包月服务");
        content.setText("必须充值包月会员才能继续使用");

        quxiao.setVisibility(View.GONE);
        kaitong.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent it = new Intent().setClass(context, B15_faxinBaoyueActivity.class);
                context.startActivity(it);
                alertDialog.cancel();
            }
        });


    }

    public static void toVIP(final Context context,String  str,boolean isCancelable){
        AlertDialog.Builder builder;
        final AlertDialog alertDialog;

        mLog.e("弹出VIP服务对话框");
        View mView = LayoutInflater.from(context).inflate(R.layout.dialog_vipfuwu, null);
//        AbDialogUtil.showDialog(mView);

        builder = new AlertDialog.Builder(context,R.style.my_dialog);
//        builder.setView(mView);
        alertDialog = builder.create();

        alertDialog.setView(mView, 0, 0, 0, 0);
        alertDialog.setCancelable(isCancelable);
        alertDialog.show();

        TextView title = (TextView) mView.findViewById(R.id.title);
        TextView content = (TextView) mView.findViewById(R.id.content);
        TextView quxiao = (TextView) mView.findViewById(R.id.quxiao);
        TextView kaitong = (TextView) mView.findViewById(R.id.kaitong);

        title.setText("VIP服务");
        content.setText(str);

        quxiao.setVisibility(View.GONE);
        kaitong.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent it = new Intent().setClass(context, B14_vipTequanActivity.class);
                context.startActivity(it);
                alertDialog.cancel();
            }
        });


    }

    public static void toYbi(final Context context,String  str){
        AlertDialog.Builder builder;
        final AlertDialog alertDialog;

        mLog.e("弹出toYbi服务对话框");
        View mView = LayoutInflater.from(context).inflate(R.layout.dialog_vipfuwu, null);
//        AbDialogUtil.showDialog(mView);

        builder = new AlertDialog.Builder(context,R.style.my_dialog);
//        builder.setView(mView);
        alertDialog = builder.create();

        alertDialog.setView(mView, 0, 0, 0, 0);
        alertDialog.setCancelable(false);
        alertDialog.show();

        TextView title = (TextView) mView.findViewById(R.id.title);
        TextView content = (TextView) mView.findViewById(R.id.content);
        TextView quxiao = (TextView) mView.findViewById(R.id.quxiao);
        TextView kaitong = (TextView) mView.findViewById(R.id.kaitong);

        title.setText("Y币服务");
        content.setText("花费20Y币，就可以和心爱的她无限畅聊了哦");

        quxiao.setVisibility(View.GONE);
        kaitong.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent it = new Intent().setClass(context, B13_yBiActivity.class);
                context.startActivity(it);
                alertDialog.cancel();
            }
        });


    }

    public static void toAibi(final Context context, final String  jname){
        AlertDialog.Builder builder;
        final AlertDialog alertDialog;

        mLog.e("弹出toAibi服务对话框");
        mLog.e("jname=" + jname);
        View mView = LayoutInflater.from(context).inflate(R.layout.dialog_vipfuwu, null);
//        AbDialogUtil.showDialog(mView);

        builder = new AlertDialog.Builder(context,R.style.my_dialog);
//        builder.setView(mView);
        alertDialog = builder.create();

        alertDialog.setView(mView, 0, 0, 0, 0);
        alertDialog.setCancelable(false);
        alertDialog.show();

        TextView title = (TextView) mView.findViewById(R.id.title);
        TextView content = (TextView) mView.findViewById(R.id.content);
        TextView quxiao = (TextView) mView.findViewById(R.id.quxiao);
        TextView kaitong = (TextView) mView.findViewById(R.id.kaitong);

        title.setText("爱币服务");
        content.setText("现在同时有不少异性正在联系"+jname+",可能没时间回复你，尝试送"+jname+"爱心礼物博取Ta的青睐，这样约会才会成功，不要小气喔");
        kaitong.setText("去送礼物");

        quxiao.setVisibility(View.GONE);
        kaitong.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent it = new Intent().setClass(context, E1_GiftShopActivity.class);
                it.putExtra("jname",jname);
                context.startActivity(it);
                alertDialog.cancel();
            }
        });


    }

    public static void toHongliang(final Context context,String  str){
        AlertDialog.Builder builder;
        final AlertDialog alertDialog;

        mLog.e("弹出toHongliang服务对话框");
        View mView = LayoutInflater.from(context).inflate(R.layout.dialog_vipfuwu, null);
//        AbDialogUtil.showDialog(mView);

        builder = new AlertDialog.Builder(context,R.style.my_dialog);
//        builder.setView(mView);
        alertDialog = builder.create();

        alertDialog.setView(mView, 0, 0, 0, 0);
        alertDialog.setCancelable(false);
        alertDialog.show();

        TextView title = (TextView) mView.findViewById(R.id.title);
        TextView content = (TextView) mView.findViewById(R.id.content);
        TextView quxiao = (TextView) mView.findViewById(R.id.quxiao);
        TextView kaitong = (TextView) mView.findViewById(R.id.kaitong);

        title.setText("红娘服务");
        content.setText("您的约会方法可能不成功，现在有资深红娘一对一帮您解决您的任何约会和情感问题");

        quxiao.setVisibility(View.GONE);
        kaitong.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent it = new Intent().setClass(context, B16_yuanfenHongniangyueActivity_new.class);
                context.startActivity(it);
                alertDialog.cancel();
            }
        });


    }

    public static void toActivity(final Context context, final Intent it,String titleStr,String contentStr){
        AlertDialog.Builder builder;
        final AlertDialog alertDialog;

        mLog.e("弹出toActivity服务对话框");
        View mView = LayoutInflater.from(context).inflate(R.layout.dialog_vipfuwu, null);
//        AbDialogUtil.showDialog(mView);

        builder = new AlertDialog.Builder(context,R.style.my_dialog);
//        builder.setView(mView);
        alertDialog = builder.create();

        alertDialog.setView(mView, 0, 0, 0, 0);
        alertDialog.setCancelable(false);
        alertDialog.show();

        TextView title = (TextView) mView.findViewById(R.id.title);
        TextView content = (TextView) mView.findViewById(R.id.content);
        TextView quxiao = (TextView) mView.findViewById(R.id.quxiao);
        TextView kaitong = (TextView) mView.findViewById(R.id.kaitong);

        title.setText(titleStr);
        content.setText(contentStr);

        quxiao.setVisibility(View.GONE);
        kaitong.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                context.startActivity(it);
                alertDialog.cancel();
            }
        });


    }

    public static void goVIP(final Context context,String contentStr){
        AlertDialog.Builder builder;
        final AlertDialog alertDialog;
        builder = new AlertDialog.Builder(context,R.style.my_dialog);
        alertDialog = builder.create();
        View mView = LayoutInflater.from(context).inflate(R.layout.dialog_vipfuwu, null);
        alertDialog.setView(mView, 0, 0, 0, 0);
        alertDialog.setCancelable(false);
        alertDialog.show();

        TextView content= (TextView) mView.findViewById(R.id.content);
        TextView quxiao= (TextView) mView.findViewById(R.id.quxiao);
        TextView kaitong= (TextView) mView.findViewById(R.id.kaitong);

        content.setText(contentStr);

        quxiao.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                alertDialog.cancel();
            }
        });
        kaitong.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent it = new Intent().setClass(context, B14_vipTequanActivity.class);
                context.startActivity(it);
                alertDialog.cancel();
            }
        });

    }

    public static void goAibi(final Context context,String contentStr){
        AlertDialog.Builder builder;
        final AlertDialog alertDialog;
        builder = new AlertDialog.Builder(context,R.style.my_dialog);
        alertDialog = builder.create();
        View mView = LayoutInflater.from(context).inflate(R.layout.dialog_vipfuwu, null);
        alertDialog.setView(mView, 0, 0, 0, 0);
        alertDialog.setCancelable(true);
        alertDialog.show();

        TextView title= (TextView) mView.findViewById(R.id.title);
        TextView content= (TextView) mView.findViewById(R.id.content);
        TextView quxiao= (TextView) mView.findViewById(R.id.quxiao);
        TextView kaitong= (TextView) mView.findViewById(R.id.kaitong);

        title.setText("爱币服务");
        content.setText(contentStr);

        quxiao.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                alertDialog.cancel();
            }
        });
        kaitong.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent it = new Intent().setClass(context, B13_aiBiActivity.class);
                context.startActivity(it);
                alertDialog.cancel();
            }
        });

    }


    public static void toZhenxinhua(final Context context,boolean isBack, final String jid, final String jicon, final String jname) {
        AlertDialog.Builder builder;
        final AlertDialog alertDialog;
        View mView = LayoutInflater.from(context).inflate(R.layout.dialog_zhenxinhuayaoqing, null);
        builder = new AlertDialog.Builder(context,R.style.zhenxinhua_dialog);
//        builder.setView(mView);
        alertDialog = builder.create();

        alertDialog.setView(mView, 0, 0, 0, 0);
        alertDialog.setCancelable(isBack);
        alertDialog.show();


        TextView icon= (TextView) mView.findViewById(R.id.icon);
        TextView quxiao = (TextView) mView.findViewById(R.id.quxiao);
        TextView kaitong = (TextView) mView.findViewById(R.id.kaitong);

        BitmapUtils bitmapUtils=new BitmapUtils(context);
        bitmapUtils.display(icon,jicon);

        kaitong.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent it = new Intent(context, B23_zhenxinhuaActivity.class);
                it.putExtra("jid", jid);
                it.putExtra("jicon", jicon);
                it.putExtra("jname", jname);
                it.putExtra("isInitiative",false);
                context.startActivity(it);
                alertDialog.cancel();
            }
        });


    }




}
